$(document).ready(function() {
    var v = $("#resignform").validate({
        submitHandler: function(form) {
            form.submit()
        },
        rules: {
            username: {
                required: true,
                minlength: 4,
                maxlength: 16,
                remote: "/account/checkuser/"
            },
            password: {
                required: true,
                rangelength: [6, 16]
            },
            password2: {
                required: true,
                rangelength: [6, 16],
                equalTo: "#password"
            }
        },
        messages: {
            username: {
                required: "请输入用户名",
                maxlength: jQuery.format("用户名最多 {0} 位"),
                minlength: jQuery.format("用户名最少 {0} 位"),
                remote: "用户名已被占用！"
            },
            password: {
                required: "请输入密码",
                rangelength: "密码输入错误"
            },
            password2: {
                required: "请再次输入密码",
                minlength: "密码确认输入错误",
                equalTo: "两次次输入不一致"
            }
        },
        errorPlacement: function(error, element) {
            element.after($('<span>').append(error));
        }

    });

});
